import {INCREMENT,DECREMENT} from '../constant/countCount'
const init ={
    count:0
}
export default  function countReducer(prevState=init,action){

        const{
            type,
            data
        }=action

        switch(type){
            case INCREMENT:
                return {
                    ...prevState,count:prevState.count+data
                };
            case DECREMENT:
                return{
                    ...prevState,count:prevState.count-data
                }
        }
        return prevState
    
}